home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: jdmorris@ix.netcom.com (Jason D. Morris)
- Newsgroups: comp.lang.c++
- Subject: Re: Bletcherous kludge!
- Date: Sat, 30 Mar 1996 03:46:55 GMT
- Organization: Netcom
- Message-ID: <315cae79.3988595@nntp.ix.netcom.com>
- References: <4jhr2b$9ou@portal.gmu.edu>
- NNTP-Posting-Host: pon-mi2-25.ix.netcom.com
- X-NETCOM-Date: Fri Mar 29 7:46:02 PM PST 1996
- X-Newsreader: Forte Agent .99d/32.182
-
- On 29 Mar 1996 23:17:31 GMT, rraffer1@osf1.gmu.edu (Ryan M Rafferty)
- wrote:
-
- >#include "String.h"
- >
- >float String::Number() {
- >
- > float i = 0;
- >
- > // this conversion method is, in its current state, a HORRIBLE and
- > // AWFUL kludge to convert the contents of a String instance to a
- > // numeric type. It doesn't do any error checking, but what's worse,
- > // it USES A TEMPORARY FILE !!!! I'm so mad at myself! But I can't
- > // seem to be able to bend the will of the iostreams class to do what
- > // I want!
- >
- > ofstream fout("./__temp");
- > fout << Buffer;
- > fout.close();
- > ifstream fin("./__temp");
- > fin >> i;
- > fin.close();
- >
- > // YECH! A feeble attempt to hide my shame...
- > // execl("/bin/rm", "rm", "./__temp", (char *) 0);
- >
- > return i;
- >};
-
- Why not just fall back on atof()?
-
- Jason
-